package vampirism.core.client;

import java.util.Timer;
import java.util.TimerTask;

import vampirism.core.shared.Network;

import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Window;


public class MenuResult {
	
    public Window window;
    
    public MenuResult(final MainGame main, boolean worldIsSaved){
    	
    	System.out.println("#CLIENT: showing result interface");
	    
    	String resultString;
    	
    	if(worldIsSaved)
    		resultString = "World Is Saved!";
    	else
    		resultString = "World Is Doomed!";
    	
	    final Label titleLabel1 = new Label("Game Over!", main.skin);
	    final Label titleLabel2 = new Label(resultString, main.skin);
	
	    window = new Window("", main.skin);
	    window.setMovable(false);
	    window.defaults().spaceRight(20);
	    window.defaults().spaceLeft(20);
	    window.defaults().spaceTop(20);
	    window.defaults().spaceBottom(20);
	    window.row().fill().expandX();
	    window.row();
	    window.add(titleLabel1).colspan(5).padTop(10);
	    window.row();
	    window.add(titleLabel2).colspan(5).padTop(10);
	    window.row();
	    window.pack();
	    
	    window.setPosition((main.W-window.getWidth())/2.0f, (main.H-window.getHeight())/2.0f);

		TimerTask launchTask = new TimerTask() {
			
			@Override
			public void run() {
				main.changeMenu(2);
			}
		};
		Timer launchTimer = new Timer();
		launchTimer.schedule(launchTask, Network.resultWaitingPeriod);
	   
	    
	    
    }
}
